<?php

/**
 * 扩展函数
 *
 * @param array $params
 * @return string
 */
function smarty_function_link($params)
{
    extract($params);
    switch ($type) {
        case 'css':
            $cssPath = Static_PATH . '/css/' . $name;
            $ret     = '<link rel="stylesheet" href="' . $cssPath . '" type="text/css">' . "\n";
            break;
        case 'js':
            $jsPath = Static_PATH . '/js/' . $name;
            $ret    = '<script src="' . $jsPath . '"></script>' . "\n";
            break;

        case 'third_tool_css':
            $path = Static_PATH . '/third_tool/' . $name;
            $ret  = '<link rel="stylesheet" href="' . $path . '" type="text/css">' . "\n";
            break;

        case 'third_tool_js':
            $jsPath = Static_PATH . '/third_tool/' . $name;
            $ret    = '<script src="' . $jsPath . '"></script>' . "\n";
            break;

        case 'css_path':
            $cssPath = Static_PATH . '/' . $name;
            $ret     = '<link rel="stylesheet" href="' . $cssPath . '" type="text/css">' . "\n";
            break;

        case 'js_path':
            $jsPath = Static_PATH . '/' . $name;
            $ret    = '<script src="' . $jsPath . '"></script>' . "\n";
            break;

        case 'images_path':
            $imagePath = Static_PATH . '/' . $name;
            $width     = isset($width) ? ' width="' . $width . '"' : '';
            $height    = isset($height) ? ' height="' . $height . '"' : '';
            $class     = isset($class) ? ' class="' . $class . '"' : '';
            $title     = isset($title) ? ' title="' . $title . '"' : '';

            $ret = '<img src="' . $imagePath . '" ' . $width . ' ' . $height . ' ' . $class . ' ' . $title . '/>' . "\n";
            break;
    }

    return $ret;
}

